<!doctype html>
<html xmlns="http://www.w3.org/1999/xhtml" id="html">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<base href="<?= base_url(1); ?>" />
<link type="text/css" href="css/main.css?v=<?= $config['version'] ?>" rel="stylesheet" />
<style type="text/css">
       #ss {
            color:blue;
         }
</style>
	<script src="js/time.js?"></script>
		<script charset="utf-8" src="edit/kindeditor.js"></script>
		<script charset="utf-8" src="edit/lang/zh_CN.js"></script>
		<script charset="utf-8" src="edit/plugins/code/prettify.js"></script>
<script type="text/javascript">
            var i = 0;
            function addp()
            {
                if (i < 4)
                {
                    i++;
                }
                else
                {
                    alert('up to four!');
                    return;
                }
                str = '<p id="p' + i + '"><input type="text" size="39" placeholder="<?= translate('PLASE_INPUT_ITEM') ?>" name="row[item][]" id="itemid' + i + '" class="autocomplete" table="type_object" autocomplete="off" >&nbsp;&nbsp;' +
                        '<input type="text" size="8" placeholder="<?= translate('PLASE_INPUT_AMOUNT') ?>" name="row[amount][]" id="num' + i + '" ></p>';
                $("#add").append(str);
                autocomplete();
            }
            function removep()
            {
                if (i > 0)
                {
                    $("#p" + i).remove();
                    i--;
                }
            }
        </script>
        
  <script type="text/javascript" language="javascript"> 
		<!-- 
		var ColorHex=new Array('00','33','66','99','CC','FF') 
		var SpColorHex=new Array('FF0000','00FF00','0000FF','FFFF00','00FFFF','FF00FF') 
		var current=null 
		function initcolor(evt) 
		{ 
			var colorTable='' 
			for (i=0;i<2;i++) 
			{ 
				for (j=0;j<6;j++) 
				{ 
					colorTable=colorTable+'<tr height=15>' 
					colorTable=colorTable+'<td width=15 style="background-color:#000000">' 
					if (i==0)
					{ 
						colorTable=colorTable+'<td width=15 style="cursor:pointer;background-color:#'+ColorHex[j]+ColorHex[j]+ColorHex[j]+'" onclick="doclick(this.style.backgroundColor)">';
					} 
					else
					{ 
						colorTable=colorTable+'<td width=15 style="cursor:pointer;background-color:#'+SpColorHex[j]+'" onclick="doclick(this.style.backgroundColor)">';
					} 
					colorTable=colorTable+'<td width=15 style="background-color:#000000">' 
					for (k=0;k<3;k++) 
					{ 
						for (l=0;l<6;l++) 
						{ 
							colorTable=colorTable+'<td width=15 style="cursor:pointer;background-color:#'+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'" onclick="doclick(this.style.backgroundColor)">';
							//colorTable=colorTable+'<td width=15 style="cursor:pointer;background-color:#'
							//	+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'" onclick="doclick(['+ColorHex[k+i*3]+ColorHex[l]+ColorHex[j]+'])">'; 
						} 
					} 
				} 
			} 
			colorTable='<table border="0" cellspacing="0" cellpadding="0" style="border:1px #000000 solid;border-bottom:none;border-collapse: collapse;width:337px;" bordercolor="000000">' 
					+'<tr height=20><td colspan=21 bgcolor=#ffffff style="font:12px tahoma;padding-left:2px;">' 
					+'<span style="float:right;padding-right:3px;cursor:pointer;" onclick="colorclose()">×关闭</span>' 
					+'</td></table>' 
					+'<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse" bordercolor="000000" style="cursor:pointer;">' 
					+colorTable+'</table>'; 
			document.getElementById("colorpane").innerHTML=colorTable; 
			var current_x = document.getElementById("inputcolor").offsetLeft; 
			var current_y = document.getElementById("inputcolor").offsetTop; 
			//alert(current_x + "-" + current_y) 
			document.getElementById("colorpane").style.left = current_x + "px"; 
			document.getElementById("colorpane").style.top = current_y + "px"; 
		} 

		function getHex(number)
		{
			res = number;
			switch(number)
			{
				case 10: res ='A';break;
				case 11: res ='B';break;
				case 12: res ='C';break;
				case 13: res ='D';break;
				case 14: res ='E';break;
				case 15: res ='F';break;
				default: res =number;break;
			}
			return res;
		}
		
		function doclick(obj){ 
			//document.write(obj);
			//alert(obj);
			
			//rgb(11,2A,3)
			//alert(obj); 		
			obj = obj.substr(4);
			//alert(obj);	
			var pos = obj.indexOf(')');
			obj = obj.substring(0,pos);
			//alert(obj);	
			var arr = new Array();
			//alert('a');
			arr = obj.split(",");
			//alert('b');
			//alert(arr.length);
			//alert('c');

			
			var res = '[';
			//alert(res);
			
			for (i=0;i<arr.length ;i++ )
			{
				if(arr[i]<16)
				{
					res += '0';
					res += getHex(arr[i]);
				}else
				{
					res += getHex(parseInt(arr[i]/16));
					res += getHex(arr[i]%16);
				}
				//alert(res);
			} 
			
			res +=']';
			//alert(res);
			
			document.getElementById("msg").value += res;
			document.getElementById("colorpane").style.display = "none"; 
		} 
		function colorclose()
		{ 
			document.getElementById("colorpane").style.display = "none"; 
			//alert("ok"); 
		} 
		function coloropen()
		{ 
			document.getElementById("colorpane").style.display = ""; 
		} 
		window.onload = initcolor; 


		KindEditor.ready(function(K) {
            var editor1 = K.create('textarea[id="msg"]', {
                //width : w,
                cssPath: 'edit/plugins/code/prettify.css',
                uploadJson: 'edit/php/upload_json.php',
                fileManagerJson: 'edit/php/file_manager_json.php',
                allowFileManager: true,
                urlType: "domain",
                afterCreate: function() {
                    var self = this;
                    K.ctrl(document, 13, function() {
                        self.sync();
                        K('form[name=rowForm]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function() {
                        self.sync();
                        K('form[name=rowForm]')[0].submit();
                    });
                }
            });
            prettyPrint();
        });
		
	</script>       
	 
</head>
<body>
<?php include(VIEWPATH . 'common/main_header.php'); ?>
<p>

</p>
<p></p>
<p></p>
<p></p>
<p>&nbsp;</p>
<p></p>
<div id="colorpane"
			style="position: absolute; z-index: 999; display: none;"> </div>
<form action="" method="POST" id="rowForm">
  <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tablegrid tableedit">
    <tr>
      <td><?= translate('SELECT_AREA') ?>
        :</td>
      <td><?= $arealist ?>
   <!--  <input name="button" type="button"
			id="inputcolor" onClick="coloropen()" value="颜色选择" />    -->
			</td>
    </tr>
    <tr>
      <td><?= translate('BROADCAST_MSG') ?>
        :</td>
      <td> <!--  <textarea rows="3" cols="60" name="row[content][msg]" id="msg"></textarea> -->
      <textarea cols="70" rows="20" name="row[content][msg]" id="msg1"></textarea>
      </td>
    </tr>
    <tr>
    <!-- <td><?= translate('BROADCAST_COUNT') ?>
        :</td>
      <td><input type="text" name="row[repeatCount]" id="repeatCount" size="25" /></td>
    </tr>
    <tr>
      <td><?= translate('BROADCAST_INTERVAL') ?>
        :</td>
      <td><input type="text" name="row[interval]" id="interval" size="25" />
        <?= translate('SECONDS') ?></td>
    </tr>  -->
    <tr>
      <td><?= translate('FREQUENCE') ?>
        :</td>
      <td><?= $frequence ?>
      </td>
    </tr>
    <tr class="hide frequence repeat">
      <td><?= translate('BROADCAST_MAX_EXCUTE_TIMES') ?>
        :</td>
      <td><input type="text" name="row[maximums]" id="maximums" value="0" /></td>
    </tr>
    <tr class="hide frequence repeat">
      <td><?= translate('RUNTIME') ?>
        :</td>
      <td><span>
        <input type="text" name="row[content][crontime][minute]" id="cronminute" class="crontime" placeholder="0-59" size="3" />
        (
        <?= translate('MINUTE') ?>
        )</span> <span>
        <input type="text" name="row[content][crontime][hour]" id="cronhour" class="crontime" placeholder="0-23" size="3" />
        (
        <?= translate('HOUR') ?>
        )</span> <span>
        <input type="text" name="row[content][crontime][day]" id="cronday" class="crontime" placeholder="1-31" size="3" />
        (
        <?= translate('DAY') ?>
        )</span> <span>
        <input type="text" name="row[content][crontime][month]" id="cronmonth" class="crontime" placeholder="1-12" size="3" />
        (
        <?= translate('MONTH') ?>
        )</span> <span>
        <input type="text" name="row[content][crontime][week]" id="cronweek" class="crontime" placeholder="0-6" size="2" />
        (
        <?= translate('WEEK') ?>
        )</span> <a href="javascript:;" class="help" module="cron">
        <?= translate('README') ?>
        </a> <span id="cron_id"></span> </td>
    </tr>
    <tr>
      <td><?= translate('STARTTIME') ?>
        :</td>
      <td><input type="text" name="row[starttime]" id="starttime" size= 25px 
      		value="<?= date("Y-m-d H:i:s") ?>" class="datepicker" showtime="true" /></td>
    </tr>
    <tr class="hide frequence repeat">
      <td><?= translate('EXPIRETIME') ?>
        :</td>
      <td><input type="text" name="row[expiretime]" id="expiretime" size= 25px value="0" class="datepicker" showtime="true" /></td>
    </tr>
    <tr>
      <td id='ss'><?= translate('BROADCAST_SELECT') ?>
        :</td>
      <td>
      <!-- <input type="checkbox" name="row[channel][]" value="5">
        <?= translate('BROADCAST_CHANNEL_SYSTEM') ?>
      	-->
        <input type="checkbox" name="row[channel][]" value="12">
        <?= translate('BROADCAST_CHANNEL_BROADCAST') ?>
        <input type="checkbox" name="row[channel][]" value="11">
        <?= translate('BROADCAST_CHANNEL_MARQUEE') ?>
      </td>
    </tr>
    <tr>
      <td></td>
      <td><input type="submit" value="<?= translate('SUBMIT') ?>" id="submit"/>
        <input type="reset" value="<?= translate('RESET') ?>" id="reset"/>
      </td>
    </tr>
  </table>
</form>
<script type="text/javascript">
    SG.init("core.form", function() {
        $.formValidator.initConfig({formid: "#rowForm", submitonce: true})
        $("#word").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
        $("#maximums").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp:"intege",datatype:"enum", onerror: '<?= translate('C_ONLY_NUM') ?>'});
        $("#repeatCount").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp:"intege",datatype:"enum", onerror: '<?= translate('C_ONLY_NUM') ?>'});
        $("#interval").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp:"intege",datatype:"enum", onerror: '<?= translate('C_ONLY_NUM') ?>'});
        $("#type").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
        $(".crontime").formValidator({empty: false, onshow: ''}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});
        $("#starttime").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).regexValidator({regexp: "^((\\d{2}(([02468][048])|([13579][26]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])))))|(\\d{2}(([02468][1235679])|([13579][01345789]))[\\-\\/\\s]?((((0?[13578])|(1[02]))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(3[01])))|(((0?[469])|(11))[\\-\\/\\s]?((0?[1-9])|([1-2][0-9])|(30)))|(0?2[\\-\\/\\s]?((0?[1-9])|(1[0-9])|(2[0-8]))))))(\\s((([0-1][0-9])|(2?[0-3]))\\:([0-5]?[0-9])((\\s)|(\\:([0-5]?[0-9])))))?$", onerror: '<?= translate('C_INVALID_TIME') ?>'});        
        $("#msg1").formValidator({empty: false, onshow: '<?= translate('PLASE_WRITE') ?>'}).inputValidator({min: 1, onerrormin: '<?= translate('C_NOT_EMPTY') ?>'});                                
        $("#frequence").change();
    });
    $("#type,#frequence").change(function() {
        var type = $(this).attr("id");
        var val = $(this).val();
        $("tr." + type).hide();
        $("." + val).show();
        $("tr." + type + " td input,tr." + type + " td textarea").unFormValidator(true);
        $("tr." + val + " td input,tr." + val + " td textarea").unFormValidator(false);
    });
</script>
</body>
</html>
